-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [QS-S3] Minor gas optimizations and consistency #305
Conversation
Summary by OctaneNew ContractsNo new contracts were added in this PR. Updated Contracts
🔗 Commit Hash: 4cd254a |
gas-snapshots/ModularAccount.json
Outdated
"Runtime_Erc20Transfer": "78454", | ||
"Runtime_InstallSessionKey_Case1": "423148", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer note: I'm not sure why, but this changed after moving ExecutionInstallDelegate
from being deployed in the constructor to being set as an immutable. Curiously, it does not affect the user op path for the install.
Contract sizes: | Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
|-------------------------------|------------------|-------------------|--------------------|---------------------|
| AccountFactory | 6,121 | 6,595 | 18,455 | 42,557 |
| AllowlistModule | 9,553 | 9,580 | 15,023 | 39,572 |
| ExecutionInstallDelegate | 5,947 | 5,993 | 18,629 | 43,159 |
-| ModularAccount | 22,401 | 29,480 | 2,175 | 19,672 |
+| ModularAccount | 22,481 | 23,537 | 2,095 | 25,615 |
| NativeFunctionDelegate | 560 | 587 | 24,016 | 48,565 |
| NativeTokenLimitModule | 4,498 | 4,525 | 20,078 | 44,627 |
| PaymasterGuardModule | 1,845 | 1,872 | 22,731 | 47,280 |
-| SemiModularAccount7702 | 23,315 | 30,387 | 1,261 | 18,765 |
-| SemiModularAccountBytecode | 23,797 | 30,876 | 779 | 18,276 |
-| SemiModularAccountStorageOnly | 24,279 | 31,358 | 297 | 17,794 |
+| SemiModularAccount7702 | 23,395 | 24,444 | 1,181 | 24,708 |
+| SemiModularAccountBytecode | 23,877 | 24,933 | 699 | 24,219 |
+| SemiModularAccountStorageOnly | 24,359 | 25,415 | 217 | 23,737 |
| SingleSignerValidationModule | 3,646 | 3,673 | 20,930 | 45,479 |
| TimeRangeModule | 2,085 | 2,112 | 22,491 | 47,040 |
| WebAuthnValidationModule | 7,854 | 7,881 | 16,722 | 41,271 | Code coverage:
|
Overview
Detailed findings
|
005856d
to
d9c4276
Compare
d9c4276
to
4cd254a
Compare
Motivation
Addresses QS-S3.
Solution
i++
to++i
and similarly forj
does not affect the gas usage when compiling withvia-ir
. This PR changes it anyways to be consistent across the codebase.executeBatch
is updated with unrolled cases for whether or not return data is needed.bytes calldata currentAuthSegment
does not change gas usage, so it is kept as-is.ModularAccountBase.isValidSignature()
is markedexternal
for consitency, though this does not change gas usage.SemiModularAccountBase._hashStructReplaySafeHash()
is kept as-is to avoid other colliding function names.ModuleManagerInternals._installValidation()
is done, though this also does not result in a gas difference.